package com.harry.resource.inner.module.api;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.harry.decoupling.defi.tool.DataExchange;
import com.harry.decoupling.impl.module.RestfulApiImpl;
import com.harry.resource.inner.entity.InnerCache;
import com.harry.utility.BeanCtxUtils;
import com.harry.utility.PoEntityHelper;

public class InnerCacheRestfulApi extends RestfulApiImpl<InnerCache> {

	@Override
	public void getone(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		DataExchange de = BeanCtxUtils.getBeanByType(DataExchange.class);
		super.getone(params, request, response, data);
		data.put("data", de.parseMap(data.get("data")));
		PoEntityHelper.writeValueByProperty(data, "data.content", de.parseMap(PoEntityHelper.readValueByProperty(data, "data.content")));
	}

	@Override
	public void post(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		DataExchange de = BeanCtxUtils.getBeanByType(DataExchange.class);
		params.put("content", de.serialize(params.get("content")));
		super.post(params, request, response, data);
	}
}
